package lc20240422;

public class MaxWater {
    public static void main(String[] args) {

        int[] height={1,8,6,2,5,4,8,3,7};
        System.out.println(maxArea(height));
    }
    public static int maxArea(int[] height) {

//        int width= height.length-1;
        int h=0;
        int left=0;
        int right=height.length-1;
        int area=0;
        while (left<right){

            if (height[left]>height[right]){
                h=height[right];
                area=Math.max(area,h*(right-left));
                right--;
            }else {
                h=height[left];
                area=Math.max(area,h*(right-left));
                left++;
            }
        }
        return area;
    }
}
